package com.caine.androidtask.ls01;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.caine.androidtask.R;

public class CustView extends Activity {
	AudioManager mAudioManager;
	int mVolume = 0;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		//		WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.caine_draw_view);
		mAudioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
		mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);

	}
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		
		
		
		if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){			
	        mAudioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,0 , 0);
	        BluetoothAdapter blue = BluetoothAdapter.getDefaultAdapter();
			blue.disable();
			Toast.makeText(this, "bluetooth is turnoff !", Toast.LENGTH_SHORT).show();
			return true;
		}
		mAudioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,mVolume , 0);
		return super.onKeyDown(keyCode, event);
	}

}
